#include<allegro.h>
#include<stdlib.h>

#include"fonction.h"
void translaterdroitmart (heros *hero,guru *gur1) {
				
			
			image=hero->img_right;
			blit(background,buffer,0,0,0,0,background->w,background->h);
		 	draw_sprite(buffer,hero->img_right,(*hero).x,(*hero).y);
			draw_sprite(buffer,image3,m,(*gur1).y+80);
			draw_sprite(buffer,image2,(*gur1).x,(*gur1).y);
			draw_sprite(buffer,image4,image4->w,image4->h);
		 	blit(buffer, screen, 0,0,0,0,SCREEN_W, SCREEN_H);
		 	(*hero).x += 1;}



void transletergauchemart(heros *hero,guru *gur1){
		 
		
		
		 image=hero->img_left;(*hero).x -= 1;
		 blit(background,buffer,0,0,0,0,background->w,background->h);
		 draw_sprite(buffer,hero->img_left,(*hero).x,(*hero).y);
		 draw_sprite(buffer,image2,(*gur1).x,(*gur1).y);
		 draw_sprite(buffer,image3,m,(*gur1).y+80);
		draw_sprite(buffer,image4,image4->w,image4->h);
		 blit(buffer, screen, 0,0,0,0,SCREEN_W, SCREEN_H);
		 }
void sursautermart(heros *hero,guru *gur1){
				if(image==hero->img_right){
			for(i=0;i<18;i++){
			j=j+1;
			(*hero).y -= i;
			(*hero).x += j/3;
			if(l>3)l=0;
			image3=gur1->marteau[l];
			m=m-2;l++;
			blit(background,buffer,0,0,0,0,background->w,background->h);
			draw_sprite(buffer,image,(*hero).x,(*hero).y);
			draw_sprite(buffer,image2,(*gur1).x,(*gur1).y);
			draw_sprite(buffer,image4,image4->w,image4->h);
			draw_sprite(buffer,image3,m,(*gur1).y+80);
			blit(buffer, screen, 0,0,0,0,SCREEN_W, SCREEN_H);
			 
	 
		attendre(0.015);
	    
			}
			for(i=0;i<18;i++){
			(*hero).y += i;
			(*hero).x += j/3;
			if(l>3)l=0;
			image3=gur1->marteau[l];
			m=m-2;l++;
			blit(background,buffer,0,0,0,0,background->w,background->h);
			draw_sprite(buffer,image,(*hero).x,(*hero).y);
			draw_sprite(buffer, image2,(*gur1).x,(*gur1).y);
			draw_sprite(buffer,image3,m,(*gur1).y+80);
			draw_sprite(buffer,image4,image4->w,image4->h);
			blit(buffer, screen, 0,0,0,0,SCREEN_W, SCREEN_H);
			
	 
		attendre(0.015);
	    
			}i=0;
			 j=0;}
			 
			 
			 
			 
			 
			 else{
			 
			for(i=0;i<18;i++){
			j=j+1;
			(*hero).y -= i;
			(*hero).x -= j/3;
			if(l>3)l=0;
			image3=gur1->marteau[l];
			m=m-2;l++;
			blit(background,buffer,0,0,0,0,background->w,background->h);
			draw_sprite(buffer,image,(*hero).x,(*hero).y);
			draw_sprite(buffer,image2,(*gur1).x,(*gur1).y);
			draw_sprite(buffer,image3,m,(*gur1).y+80);
			draw_sprite(buffer,image4,image4->w,image4->h);
			blit(buffer, screen, 0,0,0,0,SCREEN_W, SCREEN_H);
			
	 
		attendre(0.005);
	    
			}
			for(i=0;i<18;i++){
			(*hero).y += i;
			(*hero).x -= j/3;
			if(l>3)l=0;
			image3=gur1->marteau[l];
			m=m-2;l++;
			blit(background,buffer,0,0,0,0,background->w,background->h);
			draw_sprite(buffer,image,(*hero).x,(*hero).y);
			draw_sprite(buffer,image2,(*gur1).x,(*gur1).y);
			draw_sprite(buffer,image3,m,(*gur1).y+80);
			draw_sprite(buffer,image4,image4->w,image4->h);
			blit(buffer, screen, 0,0,0,0,SCREEN_W, SCREEN_H);
			
	 
		attendre(0.015);
	    
			}i=0;
			 j=0;}
		 }										
void sursautermartgau(heros *hero,guru *gur1){
												if(image==hero->img_right){
			for(i=0;i<18;i++){
			j=j+1;
			(*hero).y -= i;
			(*hero).x += j/3;
			if(l>3)l=0;image3=gur1->marteau[l];
			m=m+2;		
			l++;
			blit(background,buffer,0,0,0,0,background->w,background->h);
			draw_sprite(buffer,image,(*hero).x,(*hero).y);
			draw_sprite(buffer,image2,(*gur1).x,(*gur1).y);
			draw_sprite(buffer,image3,m,(*gur1).y+80);
			draw_sprite(buffer,image4,image4->w,image4->h);
			blit(buffer, screen, 0,0,0,0,SCREEN_W, SCREEN_H);
			 
		attendre(0.015);
	    
			}
			for(i=0;i<18;i++){
			(*hero).y += i;
			(*hero).x += j/3;
			if(l>3)l=0;
			image3=gur1->marteau[l];	
			m=m+2;l++;
			blit(background,buffer,0,0,0,0,background->w,background->h);
			draw_sprite(buffer,image,(*hero).x,(*hero).y);
			draw_sprite(buffer, image2,(*gur1).x,(*gur1).y);
			draw_sprite(buffer,image3,m,(*gur1).y+80);
			draw_sprite(buffer,image4,image4->w,image4->h);
			blit(buffer, screen, 0,0,0,0,SCREEN_W, SCREEN_H);
			
	 
		attendre(0.015);
	    
			}i=0;
			 j=0;}
			 
			 
			 
			 
	 		 
			 else{
			 
			for(i=0;i<18;i++){
			j=j+1;
			(*hero).y -= i;
			(*hero).x -= j/3;
			if(l>3)l=0;
			image3=gur1->marteau[l];
			m=m+2;
			l++;
			blit(background,buffer,0,0,0,0,background->w,background->h);
			draw_sprite(buffer,image,(*hero).x,(*hero).y);
			draw_sprite(buffer,image2,(*gur1).x,(*gur1).y);
			draw_sprite(buffer,image3,m,(*gur1).y+80);
			draw_sprite(buffer,image4,image4->w,image4->h);
			blit(buffer, screen, 0,0,0,0,SCREEN_W, SCREEN_H);
			
	 
		attendre(0.015);
	    
			}
			for(i=0;i<18;i++){
			(*hero).y += i;
			(*hero).x -= j/3;
			if(l>3)l=0;image3=gur1->marteau[l];
			m=m+2;
			l++;
			blit(background,buffer,0,0,0,0,background->w,background->h);
			draw_sprite(buffer,image,(*hero).x,(*hero).y);
			draw_sprite(buffer,image2,(*gur1).x,(*gur1).y);
			draw_sprite(buffer,image3,m,(*gur1).y+80);
			draw_sprite(buffer,image4,image4->w,image4->h);
			blit(buffer, screen, 0,0,0,0,SCREEN_W, SCREEN_H);
			
	 
		attendre(0.015);
	    
			}i=0;
			 j=0;}
		 }										

void attaquersabremart(heros* hero,guru *gur1,int *nbre){

for(i=0;i<3;i++)
	{
		if(image==hero->img_right){mag=hero->attack_sabrer[i];
					blit(background,buffer,0,0,0,0,background->w,background->h);
					draw_sprite(buffer,mag,(*hero).x,(*hero).y);
					draw_sprite(buffer,image2,(*gur1).x,(*gur1).y);
					draw_sprite(buffer,image4,image4->w,image4->h);
					draw_sprite(buffer,image3,m,(*gur1).y+80);
					blit(buffer, screen, 0,0,0,0,SCREEN_W, SCREEN_H);}

		if(image==hero->img_left){mag=hero->attack_sabrel[i];
					blit(background,buffer,0,0,0,0,background->w,background->h);
					draw_sprite(buffer,mag,((*hero).x)-50,(*hero).y);
					draw_sprite(buffer,image2,(*gur1).x,(*gur1).y);
					draw_sprite(buffer,image4,image4->w,image4->h);
					draw_sprite(buffer,image3,m,(*gur1).y+80);
					blit(buffer, screen, 0,0,0,0,SCREEN_W, SCREEN_H);}
	
	attendre(0.01);
	}
	if((*hero).x<((*gur1).x+50) && ((*hero).x>((*gur1).x))){*nbre=*nbre-1;}
}





